﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace QUANLIBANHANG.DAL
{
    public class BackupRestoreDAL
    {
        // Hàm thực hiện Backup dử liệu
        public static void backUpData(string pathFile)
        {
            try
            {
                ConnectionSQL.commandSQL("BACKUP DATABASE QUANLIBANHANG TO DISK='" + pathFile+ "' WITH FORMAT");
            }
            catch ( Exception e)
            {
                
                throw e;
            }
        }
        // Hàm thực hiện Restore
        public static void restoreData(string pathFile)
        {
            try
            {
                ConnectionSQL.commandSQL("ALTER DATABASE QUANLIBANHANG SET OFFLINE WITH ROLLBACK IMMEDIATE USE master"
                       + " RESTORE DATABASE QUANLIBANHANG FROM DISK= '" + pathFile + "' WITH REPLACE ALTER DATABASE QUANLIBANHANG SET ONLINE");
            }
            catch (Exception e)
            {
                
                throw e;
            }
        }
    }
}
